<?php

/*
 * File  : statik.php
 * Table : statik, kategoris
 */
//session_start();
//cek session

if ((!$_SESSION["USRID"] AND !$_SESSION["USRPASS"])) {
    header("location: ../index.php");
    exit();
}
//end
?>

<?php

$aksi = "cms/bab/m_statik/aksi_statik.php";
switch ($_GET["opr"]) {

// tampil statik
    default:
        echo "<h2>Statistik</h2>";
        echo " <input type=button value='Tambah statik' onclick=\"window.location.href='?module=statik&opr=tambah';\">";
        echo " <table>";
        echo "  <tr><th>No</th><th>Nama Statik</th><th>Seo Statik</th><th>Deskripsi</th><th>Aksi</th></tr>";

        $p = new Paging;
        $batas = 10;
        $posisi = $p->cariPosisi($batas);

        $tampil = mysql_query("SELECT * FROM statiks ORDER BY statik_id DESC LIMIT $posisi, $batas");

        $no = $posisi + 1;
        while ($row = mysql_fetch_array($tampil)) {

            echo "<tr><td>$no</td>";
            echo " <td>" . $row["statik_nama"] . "</td>";
            echo " <td>" . $row["statik_seo"] . "</td>";
            echo " <td>" . substr($row["statik_isi"], 0, 10) . "</td>";
            echo " <td><a href='?module=statik&opr=edit&id=" . $row["statik_id"] . "'>Edit</a> | 
		                <a href='" . URLHOST . "$aksi?module=statik&opr=hapus&id=" . $row["statik_id"] . "'  onClick=\"return confirm('Hapus statik " . $row["statik_nama"] . "?')\" >Hapus</a>";
            echo " </td></tr>";
            $no++;
        }
        echo "</table>";

        $jmldata = mysql_num_rows(mysql_query("SELECT * FROM statiks"));
        $jmlhalaman = $p->jumlahHalaman($jmldata, $batas);
        $linkHalaman = $p->navHalaman($_GET["halaman"], $jmlhalaman);

        echo "<div id=paging>Hal: $linkHalaman</div><br>";
        break;

// tambah statik
    case "tambah":
        load_tinymce();
        echo "<h2>Tambah Statik</h2>";
        echo " <form method='POST' action='" . URLHOST . "$aksi?module=statik&opr=input' enctype='multipart/form-data'>";
        echo " <table>";
        echo "  <tr><td width=70>Nama statik</td><td> : <input type='text' name='in_statik_nama' size='60'></td></tr>";

        echo "  <tr><td>Deskripsi</td><td> <textarea name = 'in_statik_deskripsi' style = 'width: 600px; height: 350px;'></textarea></td></tr>";
        echo "  <tr><td colspan='2'><input type ='submit' value ='Simpan'>";
        echo "  <input type ='button' value ='Batal' onclick ='self.history.back()'></td></tr>";
        echo " </table>";
        echo " </form>";
        break;

    case "edit":
        load_tinymce();
        $edit = mysql_query("SELECT * FROM statiks WHERE statik_id = '" . $_GET["id"] . "'");
        $row = mysql_fetch_array($edit);

        echo "<h2>Edit statik</h2>";
        echo " <form method='POST' action ='" . URLHOST . "$aksi?module=statik&opr=update' enctype='multipart/form-data'>";
        echo " <input type ='hidden' name ='id' value ='" . $row["statik_id"] . "'>";
        echo " <table>";
        echo "  <tr><td width = 70>Nama statik</td> <td> : <input type='text' name = 'in_statik_nama' size ='60' value = '" . $row["statik_nama"] . "'></td>";
        echo "  <tr><td>Deskripsi</td> <td> <textarea name = 'in_statik_deskripsi' style = 'width: 600px; height: 350px;'>" . $row["statik_isi"] . "</textarea></td></tr>";
        echo "  <tr><td colspan = 2><input type ='submit' value ='Update'><input type ='button' value ='Batal' onclick = self.history.back()></td></tr>";
        echo "  </table></form>";
        break;
}
?>
